package pt.iscte.pcd.banquet;

import java.util.Random;

public class Gluton extends Thread {

	private static final int MAX_CONSUME_TIME = 1000;
	private static final int N_BOARS = 10;
	private Table table;
	private int n;

	public Gluton(Table table) {
		this.table = table;
	}

	@Override
	public void run() {
		Random gen = new Random();
		while (n != N_BOARS) { // (!interrupted()) {
			Boar j = table.get();
			System.out.println(this + " consumiu " + j);
			n++;
			// eat
			try {
				sleep(gen.nextInt(MAX_CONSUME_TIME));
			} catch (InterruptedException e) {
				// interrupt(); 
			}
		}

	}

}
